<?
//?erpr?? o der Abruf ?? die Hauptseite erfolgt
if(!defined('InStern')) exit;
?>
<h1>Galaxyansicht</h1>
<script type="text/javascript">
var quickplaceId=new Array();
var quickplaceName=new Array();
var quickplaceX=new Array();
var quickplaceY=new Array();
<?
  $abfrage = "SELECT * FROM quickplace where Spieler='$_SESSION[spielerId]' and Server='" . $_SESSION[server][Id] . "';";
  $result=$db->query($abfrage);
  $anzahl= $db->num_rows($result);
  $a=0;
  while($row = $db->fetch_assoc($result)) 
  {
    echo "
    quickplaceId[$a]=$row[Id];
    quickplaceName[$a]='$row[Name]';
    quickplaceX[$a]=$row[PosX];
    quickplaceY[$a]=$row[PosY];";
    $a++;
  }
?>
function quickplace()
{
  document.getElementById('selectQuickplace').length=1;
  for(i=0;quickplaceName[i];i++) document.getElementById('selectQuickplace').options[i+1]=new Option(quickplaceName[i],[i],false, false);
  document.getElementById('selectQuickplace').options[i+1]=new Option("- Quickplace hinzufügen -","-1",false, false);
}
function loadquickplace()
{
  if(resObjekt.readyState==4)
  {
    var quickplaces=resObjekt.responseText.split('*|*');    
    var a=0;
    for(i=1;quickplaces[i];i++)
    {      
      quickplaceId[a]=quickplaces[i++];
      quickplaceName[a]=quickplaces[i++];
      quickplaceX[a]=quickplaces[i++];
      quickplaceY[a]=quickplaces[i];
      a++;
    }
    quickplace();
  }
}
function newquickplace()
{
  var name=prompt("Wie soll der Quickplace hei?n?","Quickplace");
  if(name!=null)
  {
    var X=document.getElementById('inputX').value;
    var Y=document.getElementById('inputY').value;
    resObjekt.abort();
    resObjekt.open("get","ajax/quickplace.ajax.php?do=add&name="+name+"&x="+X+"&y="+Y,true);
    resObjekt.onreadystatechange=loadquickplace;
    resObjekt.send(null);
  }
}
function erasequickplace(id)
{
  resObjekt.abort();
  resObjekt.open("get","ajax/quickplace.ajax.php?do=erase&id="+quickplaceId[id],true);
  resObjekt.onreadystatechange=loadquickplace;
  resObjekt.send(null);
}
function openquickplace(id)
{
  document.getElementById('inputX').value=quickplaceX[id];
  document.getElementById('inputY').value=quickplaceY[id];
  moveto();
} 
  
function moveto()
{
  window.galaxy.X=parseInt(document.getElementById('inputX').value);
  window.galaxy.Y=parseInt(document.getElementById('inputY').value);
  window.galaxy.createview();
}
function catchSektor(feld)
{
  var left=parseInt(document.getElementById('uebersicht').left);
  var top=parseInt(document.getElementById('uebersicht').left);
  document.getElementById('rahmen').style.left=event.clientX+"px";
}
</script>
<table  onmouseover="window.galaxy.maus=false;">
 <tr class="table_head2">
  <th height="20">
   <select id="selectQuickplace" style="width:170px" onChange="if(this.value==-1) newquickplace(); else openquickplace(this.value);">
    <option value="0">Quickplace wählen</option>
    <option value="-1">Quickplace hinzufügen</option>
   </select>
   <input type="button" value="X" onclick="if(document.getElementById('selectQuickplace').value>=0) if(confirm('Willst du den Quickplace wirklich löschen?')) erasequickplace(document.getElementById('selectQuickplace').value);" />
   &nbsp;
   &nbsp;
   <input type="checkbox" checked="checked" onchange="if(this.checked)window.galaxy.raster=true; else window.galaxy.raster=false; window.galaxy.createview();" ><img src="images/raster.png"></input>
   &nbsp;
   &nbsp;
   <input type="button" value="map" onclick="if(document.getElementById('uebersicht').style.display=='none') document.getElementById('uebersicht').style.display='block'; else document.getElementById('uebersicht').style.display='none';">
   <input type="button" value="home" onclick="document.getElementById('inputX').value=<?echo $planet[PosX]?>; document.getElementById('inputY').value=<?echo $planet[PosY]?>;moveto();">
   &nbsp;
   &nbsp;
   Koors:
   <input type="text" id="inputX" name="inputX" size="2" value="0" onkeyup="if(event.keyCode==13) moveto();"/>:
   <input type="text" id="inputY" name="inputY" size="2" value="0" onkeyup="if(event.keyCode==13) moveto();"/>
   <input type="button" value="los" onclick="moveto();"/>
   &nbsp;
   &nbsp;
   Zoom:
   <input type="button" value="+" onclick="window.galaxy.zoomin(window.galaxy.zoom+10);window.galaxy.createview();"/>
   <input type="button" value="-" onclick="window.galaxy.zoomout(window.galaxy.zoom-10);window.galaxy.createview();"/>
   <span id="status"></span>

  </th>
 </tr>
 <tr>
  <th>
   <iframe width="720" height="500" name="galaxy" id="galaxy" style="border-style:none;" src="<?echo "galaxy.php?x=$planet[PosX]&y=$planet[PosY]";?>" scrolling="no"></iframe>
  </th>
 </tr>

</table>

<table style="position:absolute; top:280px; left:340px; width:500px; display:none;" cellspacing="0" id="uebersicht">
 <tr class="table_head1">
  <th>?ersichtskarte</th>
  <th align="right"><input type="button" value="X" style="padding:0px; height:12px; font-size:10px;" onclick="document.getElementById('uebersicht').style.display='none';"></th>
 </tr>
 <tr>
  <th colspan="2">
   <iframe src="ajax/minimap.ajax.php" style="border-style:none; width:400px; height:400px; overflow:hidden;"></iframe>
  </th>
 </tr>
</table>
<script type="text/javascript">
  quickplace();
</script>